﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Power.Control;
using Power.View;
using Power.View.Dialog;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;

namespace Power.ViewModel
{
    public class AIToolViewModel : ViewModelBase
    {
        //private DispatcherTimer timer = new DispatcherTimer();
        //private AITool model;
        //public AIToolViewModel(AITool model)
        //{
        //    this.model = model;
        //    this.model.Loaded += AITool_Loaded;
        //    this.model.mediaElement.Source = new Uri(System.AppDomain.CurrentDomain.BaseDirectory + $@"\Resources\video\123.mp4", UriKind.Absolute);
        //    OpenList = new RelayCommand(OnOpenList);
        //    CloseList = new RelayCommand(OnCloseList);
        //    ShowAddDefects = new RelayCommand(OnShowAddDefects);
        //    Start = new RelayCommand(OnStart);
        //    Pause = new RelayCommand(OnPause);
        //    OnStart();
        //    #region 列表
        //    SelectedItemEvent = SetPosition;
        //    SiteList = new ObservableCollection<SiteModel>();
        //    for (int i = 0; i < 3; i++)
        //    {
        //        var ex = new SiteModel
        //        {
        //            ID = i + 1,
        //            ProjectName = "Name_" + (i + 1).ToString(),
        //            SubName = "Name_" + (i + 1).ToString(),
        //            SiteName = "Name_" + (i + 1).ToString(),
        //            Count = i + 1
        //        };
        //        SiteList.Add(ex);
        //    }
        //    #endregion
        //}

        //public void SetPosition()
        //{
        //    this.model.mediaElement.Position = TimeSpan.FromSeconds(2);
        //    this.model.mediaElement.Pause();
        //    this.model.btnStart.Visibility = Visibility.Visible;
        //    this.model.btnPause.Visibility = Visibility.Hidden;
        //}

        ///// <summary>
        ///// 暂停播放
        ///// </summary>
        //private void OnPause()
        //{
        //    this.model.mediaElement.Pause();
        //    this.model.btnStart.Visibility = Visibility.Visible;
        //    this.model.btnPause.Visibility = Visibility.Hidden;
        //}

        ///// <summary>
        ///// 进度
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void Timer_Tick(object sender, EventArgs e)
        //{
        //    this.model.time.Content = string.Format("{0:00}:{1:00}:{2:00}",
        //    this.model.mediaElement.Position.Hours,
        //    this.model.mediaElement.Position.Minutes,
        //    this.model.mediaElement.Position.Seconds);


        //    this.model.volumeSlider.Value = this.model.mediaElement.Position.TotalSeconds;

        //    if (this.model.mediaElement.Position.TotalSeconds == this.model.volumeSlider.Maximum)
        //    {
        //        OnPause();
        //    }
        //}

        ///// <summary>
        ///// 计时器
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void AITool_Loaded(object sender, RoutedEventArgs e)
        //{
        //    this.timer.Interval = TimeSpan.FromMilliseconds(500);
        //    timer.Tick += Timer_Tick;
        //    timer.Start();
        //}

        ///// <summary>
        ///// 开始播放
        ///// </summary>
        //private void OnStart()
        //{
        //    this.model.mediaElement.Play();
        //    this.model.btnStart.Visibility = Visibility.Hidden;
        //    this.model.btnPause.Visibility = Visibility.Visible;
        //}

        ///// <summary>
        ///// 添加缺陷点击
        ///// </summary>
        //private void OnShowAddDefects()
        //{
        //    AddDefects.ShowDialog(Window.GetWindow(this.model));
        //}

        ///// <summary>
        ///// 左侧列表开启
        ///// </summary>
        //private void OnOpenList()
        //{
        //    this.model.left1.Visibility = Visibility.Collapsed;
        //    this.model.left2.Visibility = Visibility.Visible;
        //    this.model.grid.ColumnDefinitions[0].Width = new GridLength(270);
        //    this.model.right1.Margin = new Thickness(-216, 0, 0, 0);
        //    Panel.SetZIndex(this.model.left2, this.model.grid.Children.Count + 1);
        //}

        ///// <summary>
        ///// 左侧列表关闭
        ///// </summary>
        //private void OnCloseList()
        //{
        //    this.model.left1.Visibility = Visibility.Visible;
        //    this.model.left2.Visibility = Visibility.Collapsed;
        //    this.model.grid.ColumnDefinitions[0].Width = new GridLength(37);
        //    this.model.right1.Margin = new Thickness(17, 0, 0, 0);
        //}

        //#region Command
        //public RelayCommand OpenList { get; private set; }

        //public RelayCommand CloseList { get; private set; }

        //public RelayCommand ShowAddDefects { get; private set; }

        //public RelayCommand Start { get; private set; }

        //public RelayCommand Pause { get; private set; }
        //public ObservableCollection<SiteModel> SiteList
        //{
        //    get
        //    {
        //        return siteList;
        //    }
        //    set
        //    {
        //        siteList = value;
        //        RaisePropertyChanged();
        //    }
        //}
        //#endregion

        //#region 列表
        //private ObservableCollection<SiteModel> siteList;
        //private SiteModel selectedItem;
        //public SiteModel SelectedItem
        //{
        //    get
        //    {
        //        return selectedItem;
        //    }
        //    set
        //    {
        //        selectedItem = value;
        //        if (SelectedItemEvent != null)
        //            SelectedItemEvent();
        //        RaisePropertyChanged();
        //    }
        //}
        //public class SiteModel : INotifyPropertyChanged
        //{
        //    public int ID { get; set; }
        //    public string ProjectName { get; set; }
        //    public string SubName { get; set; }
        //    public string SiteName { get; set; }
        //    public int Count { get; set; }
        //    private bool isSelectedFlag;
        //    public bool IsSelectedFlag
        //    {
        //        get
        //        {
        //            return isSelectedFlag;
        //        }
        //        set
        //        {
        //            isSelectedFlag = value;
        //            RaisePropertyChanged();
        //        }
        //    }
        //    public event PropertyChangedEventHandler PropertyChanged;

        //    public void RaisePropertyChanged([CallerMemberName] string property = "")
        //    {
        //        this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
        //    }
        //}
        //#endregion

        //public Action SelectedItemEvent { get; set; }
    }
}
